/**
 * Created with magedrupal.com.
 * User: baonv
 * Date: 1/12/13
 * Time: 2:41 PM
 */

(function() {
    jQuery(document).ready(function() {
        
        var mdSliderPanel = new MdSliderPanel();
        mdSliderPanel.init();        
        jQuery('a#choose-slide-bg').live('click',function () {
            var _self = jQuery(this);
            Drupal.media.popups.mediaBrowser(function (mediaFiles) {
                var icon = mediaFiles[0];
                jQuery('input[type=text]', _self.parent()).val(icon.url);
                jQuery('input[type=hidden]', _self.parent()).val(icon.fid);
            });
            return false;
        });
        // Get data for save
        jQuery('#md-slider-edit-form').submit(function() {
            console.log(jQuery.objectToString(mdSliderPanel.getSliderData()));
            jQuery("#edit-slider-data-save").val(jQuery.objectToString(mdSliderPanel.getSliderData()));
        });
        jQuery("#edit-slider-submit").click(function() {
            jQuery("#dlg-slide-data").html(jQuery.objectToString(mdSliderPanel.getSliderData()));
            return false;
        });
    });
})(jQuery);